package com.poizon.example.controller;

import com.poizon.infrastructure.idem.core.annoations.Idempotent;
import com.poizon.infrastructure.idem.core.util.IIdemUtil;
import com.poizon.infrastructure.idem.core.util.impl.IdemUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@Slf4j
@Service
@RestController
@RequestMapping("/test")
public class TestController implements TestService {
    @Autowired
    private IIdemUtil idemUtil;
    @Idempotent(value = "{#id}", expireTime = 10, retryTimes = 3, timeUnit = TimeUnit.SECONDS, reqType = "HTTP")
    @GetMapping("test")
    public String testtt(
            @RequestParam(value = "id", required = false) String id
    ) {
        log.info(">1111", "");
        return id;
    }

    @Idempotent(value = "{#id}", expireTime = 10, retryTimes = 3, timeUnit = TimeUnit.SECONDS, reqType = "HTTP")
    @Override
    public void test(String id) {
        log.info(">1111", "");
    }
}
